package com.oppo.userServer.config.mybatisPlus;


import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author 清梦
 * @version 1.0.0
 * @Description mybatisPlus字段自动填充配置
 * @createTime 2023年04月16日 15:30:00
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName( "createTime", new Date(),metaObject);
        this.setFieldValByName( "updateTime", new Date(),metaObject);
        this.setFieldValByName( "isDeleted", 1,metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName( "updateTime", new Date(),metaObject);
    }

}